<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../jquery-1.11.2.min.js"></script>
</head>
<body>
<h2>两个select选择后，另外一个select才被赋值</h2>

<h2>select1</h2>
<select name="cost" id="select1" class="select_class">
    <option value="0" >请选择</option>
    <option value="1" selected>1</option>
    <option value="2">2</option>
</select>

<select name="cost" id="select2" class="select_class">
    <option value="0" >请选择</option>
    <option value="11" selected >11</option>
    <option value="22">22</option>
</select>

<h2>select_ok</h2>
<select name="select_ok" id="select_ok">
    <option value="0">请选择</option>
</select>



<script>

    $(function () {

        //1、获取一组select的数量
        var select_count = $(".select_class").length;

        //2、判断一组select是否有空值 $.each
        //3、当一组select有值的话，给另外一个select赋它的值
        var newcost = [];
        var newstring;
        var obj = $('[name=cost]');
        var html = '';
        $.each(obj,function (index,item) {
            newstring = $(item).find("option:selected").val();
            html += '<option>'+$(item).find("option:selected").text()+'</option>';
            if(result == '0'){
                console.log('需要全部选择完再才能进行');
                return false;
            }
            newcost.push(newstring);
        });
        console.log(html);
        var result = newcost.indexOf('0').toString();
        console.log(result);
        if(result == "-1"){

            $("#select_ok").append(html);
        }else{
            return false;
        }








    })
</script>
</body>
</html>